const vs = "\n" +
    "#include <fog_pars_vertex>\n" +
    "varying vec2 vUv;\n\n" +
    "varying vec3 vNormal;\n" +
    "varying vec3 vViewDir;\n" +
    "void main() {\n" +
    "vUv = uv;\n\n" +
    "vNormal = normalize(normalMatrix * normal);\n" +
    "vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n" +
    "vViewDir = -viewPosition.xyz;\n" +
    "gl_Position = projectionMatrix * viewPosition;\n\n" +
    "#include <begin_vertex>\n" +
    "#include <project_vertex>\n" +
    "#include <fog_vertex>\n" +
    "}\n";

const fs = "\n" +
    "#include <common>\n" +
    "#include <packing>\n" +
    "#include <fog_pars_fragment>\n\n" +
    "varying vec3 vNormal;\n" +
    "varying vec3 vViewDir;\n" +
    "varying vec2 vUv;\n" +
    "uniform sampler2D depthTexture;\n" +
    "uniform sampler2D noiseTexture;\n" +
    "uniform float cameraNear;\n" +
    "uniform float cameraFar;\n" +
    "uniform float time;\n" +
    "uniform vec2 resolution;\n" +
    "uniform vec3 intersectionColor;\n" +
    "uniform vec3 hexPatternColor;\n" +
    "uniform vec3 rimColor;\n\n" +
    "float getDepth(const in vec2 screenPosition) {\n" +
    "return unpackRGBAToDepth(texture2D(depthTexture, screenPosition));\n" +
    "}\n\n" +
    "float getViewZ(const in float depth) {\n" +
    "return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n" +
    "}\n\n" +
    "void main() {\n" +
    "vec2 screenUV = gl_FragCoord.xy / resolution;\n" +
    "float fragmentLinearEyeDepth = getViewZ(gl_FragCoord.z);\n\n" +
    "float linearEyeDepth = getViewZ(getDepth(vec2(screenUV.x, screenUV.y)));\n" +
    "float depthDifference = saturate(fragmentLinearEyeDepth - linearEyeDepth);\n\n" +
    "float intersectionGray = 1.0 - smoothstep(0.0, 0.5, depthDifference);\n" +
    "vec3 intersectionColored = intersectionGray * intersectionColor;\n" +
    "\n" +
    "float hexPatternGray = texture(noiseTexture, vUv * 10.0).r;\n" +
    "vec3 hexPatternColored = hexPatternGray * hexPatternColor;\n" +
    "\nvec3 viewDir = normalize(-vViewDir);\n" +
    "float rimStrength = 1.0 - abs(dot(viewDir, vNormal));\n\n" +
    "float rimGray = pow(rimStrength, 2.0);\n" +
    "float rimGray2 = pow(rimStrength, 1.0);\n" +
    "vec3 rimColored = rimGray2 * rimColor;\n\n" +
    "float final = intersectionGray + rimGray * hexPatternGray;\n" +
    "vec3 finalColored = intersectionColored  + hexPatternColored + rimColored;\n\n" +
    "gl_FragColor = vec4(vec3(finalColored), final);\n\n" +
    "#include <tonemapping_fragment>\n" +
    "#include <encodings_fragment>\n" +
    "#include <fog_fragment>\n" +
    "}\n            ";

export {vs, fs};
